// JavaScript Document

function Common()
{
	this.init();	
}

Common.prototype={
	init:function()
	{
		var _this = this;
		_this.liveVideo();	
		//游戏专区
		_this.nav($(".navGameZq"),$(".gamePopWrap"),$(".gameZq"));
		//关注
		_this.nav($(".btnFollow"),$(".followGz"),$(".navInput .btnFollow .niLink"));
		//下载
		_this.nav($(".btnDownload"),$(".popDownload"),$(".navInput .btnDownload .niLink"));
		//个人中心
		_this.nav($(".loggedWrap"),$(".navCenter"),$(".navInput .loggedWrap .niLink"));
		//返回顶部
		_this.rightSide();
		//登录
		_this.login();
		_this.setMainHeight();
		_this.liveWrapLeft();
	},
	//左边固定
	liveWrapLeft:function()
	{
		$(window).on("load resize scroll",function()
		{
			var sTop = $(window).scrollTop();
			if(sTop>=74)
			{
				$(".liveWrapLeft").css("position","fixed");
			}
			else
			{
				$(".liveWrapLeft").css("position","absolute");	
			}
		});
	},
	//内容不足固定高度
	setMainHeight:function()
	{
		$(window).on("load resize",function()
		{
			if($(".footer").size()!=0)
			{
				$(".main").css({"min-height":($(window).height()-107-$(".footer").get(0).offsetHeight)+"px"});
			}
		})
	},
	//王者荣耀直播
	liveVideo : function()
	{
		$(".alList,.alList2").each(function()
		{
			var self = $(this);
			self.find("li").on("mouseover",function()
			{
				$(this).find(".alPlay").css({"transform":"scale(1)"}).stop().animate({"opacity":"0.9"});
				$(this).find(".alMask").stop().animate({"opacity":"0.7"});
			});	
			
			self.find("li").on("mouseout",function()
			{
				$(this).find(".alPlay").css({"transform":"scale(1.8)"}).stop().animate({"opacity":"0"});
				$(this).find(".alMask").stop().animate({"opacity":"0"});
			});	
		});
	},
	//修改
	nav:function(obj,popBox,aHover)
	{
		var timer = null;
		var popTop = parseInt(popBox.css("top"));
		obj.on("mouseover",function()
		{
			clearTimeout(timer);
			popBox.show().stop().animate({"opacity":1,"top":(popTop+10)+"px"});
			aHover.addClass("navHover");
		});
		obj.on("mouseout",function()
		{
			clearInterval(timer);
			aHover.removeClass("navHover");
			timer=setTimeout(function()
			{				
				popBox.stop().animate({"opacity":0,"top":popTop+"px"},function()
				{
					popBox.hide();
				});
			},300);
		});
	},
	rightSide:function()
	{
		//app
		$(".btnApp").bind("mouseover",function()
		{
			$(this).find("img").show().stop().animate({"opacity":1,"left":"-200px"});
		});	
		$(".btnApp").bind("mouseout",function()
		{
			$(this).find("img").stop().animate({"opacity":0,"left":"-180px"},function()
			{
				$(".btnApp").find("img").css("display","none");
			});
		});
		//公众号
		$(".btnGzh").bind("mouseover",function()
		{
			$(this).find("img").show().stop().animate({"opacity":1,"left":"-200px"});
		});	
		$(".btnGzh").bind("mouseout",function()
		{
			$(this).find("img").stop().animate({"opacity":0,"left":"-180px"},function()
			{
				$(".btnGzh").find("img").css("display","none");
			});
		});
		//返回顶部
		$(window).bind("load resize scroll",function()
		{
			if($(window).scrollTop()>=300)
			{
				$(".btnBack").stop().animate({"opacity":1});
			}
			else
			{
				$(".btnBack").stop().animate({"opacity":0});
			}	
		});
		$(".btnBack").bind("click",function()
		{
			$('body,html').animate({scrollTop:0},500);
   		});
		
		$(".sideRight li a").bind("mouseover",function()
		{
			$(this).find("em").stop().animate({"top":0});	
		});
		
		$(".sideRight li a").bind("mouseout",function()
		{
			$(this).find("em").stop().animate({"top":"60px"});	
		});
	},
	login:function()
	{
		$(".btnLogin").on("click",function()
		{
			if($(".telNo").val()=="" || $(".telPwd").val()=="")
			{
				$(".error").fadeIn(200);
				setTimeout('$(".error").fadeOut()', 2000);
			}	
		});	
	}
}
$(function()
{
	var common = new Common();	
});